namespace array_demo.Model.Queue
{

    /// <summary>
    /// 循环数组
    /// </summary>
    /// <typeparam name="E"></typeparam>
    public class ArrayQueue2<E> : IQueue<E>
    {
        private Array2<E> array;
    
        public ArrayQueue2(int capacity)
        {
            array = new Array2<E>(capacity);
        }

        public ArrayQueue2()
        {
            array = new Array2<E>();
        }

        public int Count => array.Count;

        public bool IsEmpty => array.IsEmpty;

        public E Dequeue()
        {
            return array.DeleteFirst();
        }

        public void Enqueue(E e)
        {
            array.AddLast(e);
        }

        public E Peek()
        {
            return array.GetFirst();
        }
    }
}